#ifndef _DECODE_H_
#define _DECODE_H_


//_Bool Data_FB	@PA_IDR:0;


/*********Communication Paraameter defined*****************/
#ifdef Decode_Global
#define Decode_EXT   
#else
#define Decode_EXT extern
#endif
/****************************************************************/

#define DECODE_PORT		GPIOA
#define DECODE_PIN		GPIO_PIN_3

/****************************************************************/
#define DecodeDelayMaxValue		65000
#define DecodeSofTimeoutValue		500
#define DecodeSofTimeMinValue	5
#define DecodeBitTime				603
#define AuthCode					0xaa
#define AuthTimeOut				60000
#define TotalChrgTime				250//(mintues)
#define Chrg_ErrLimit				2
/****************************************************************/

#define Data_FB ((GPIO_ReadInputPin(DECODE_PORT, DECODE_PIN))?1:0)

typedef enum
{
	DecodeSOF=0,
	DecodeData
}
DECODE_PACKET;

typedef struct
{
	volatile unsigned char LowProcessFlag:1;
	volatile unsigned char DecodeSuccess:1;
	volatile unsigned char DataFristBitSuccess:1;
}
DECODE_STATUS;

typedef struct
{
	volatile DECODE_PACKET Decode_Packet;
	volatile DECODE_STATUS Decode_Status;
	volatile unsigned int delay;
	volatile unsigned char BitOffSet;
	volatile unsigned char DataValue;
	volatile unsigned char DataBackUpValue;
	volatile unsigned int   AuthTimeoutValue;
	volatile unsigned char RemainTime;
	volatile unsigned char DisValue;
	volatile unsigned char Segment;
	volatile unsigned int    DecodeStartCnt;

	void (*USER_APP)(void);
	
}
DECODE_PARA;

/****************************************************************/
void Decode_IoInit(void (*UAPP)(void));

void Decode_InterruptHandler(void);
void Decode_Handler(void);
void Decoe_DataHandler(void);
#endif
